from race.Player import *
import logging.config
from threading import Thread

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")

"""
    子类描述：
        1、增强萨满类
"""


class EnhanceShaman(Player):
    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        # super().a()

        self.click(self.kb, '9', 3)

        # ★★★★★并行|并发★★★★★----------------parallel:`1   Alt2     cap3    shift4   ctrl5
        self.kb.press('`')  # 触发-->parallel1
        self.kb.release('`')

        self.kb.press(Key.alt_l)
        self.kb.release(Key.alt_l)

        self.kb.press(Key.caps_lock)
        self.kb.release(Key.caps_lock)

        # self.kb.press(Key.ctrl_l)
        # self.kb.release(Key.ctrl_l)
        #
        # self.kb.press(Key.ctrl_r)
        # self.kb.release(Key.ctrl_r)
        while self.ui.stopLoop == False:
            # 血量低于多少，增强自己给自己治疗 1048->1060     230->185   10,10->3,3
            self.pubAvgColorTiggerKeyBloodBarMode(520, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', '0', 0.7, 7)

            # 血量高于多少，继续打闪电(目前有问题，后续修正)
            # self.pubAvgColorTiggerKeyBuffMode(32, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                   self.WA_SQUARE_ZFX_AvgColor,
            #                                   'r', 'big', 'o', 0.1, 2)

    def parallel1(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        while self.ui.stopLoop == False:
            self.click(self.kb, '1', 3)
            sleep(0.1)
            self.click(self.kb, '3', 3)
        return

    def parallelAlt2(self):
        # # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        # while self.ui.stopLoop == False:
        #     self.click(self.kb, '1', 3)
        #     sleep(0.1)
        #     self.click(self.kb, '3', 3)
        pass
        return

    def parallelCap3(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.click(self.kb, '4', 3)
        while self.ui.stopLoop == False:
            strTempDate = int(datetime.datetime.now().strftime('%S'))
            # strTempDate = datetime.datetime.now().strftime('%S')
            # strTempDate = '555555'
            if strTempDate in ('0', '2', '4', '6', '8'):
                pass
            elif strTempDate in ('1', '4', '7', '9'):
                pass
            elif strTempDate in ('3', '8'):
                pass
            else:
                pass

            # -1 最后一位支付；-2倒数第二位字符
            if strTempDate > 55:
                self.click(self.kb, '9', 3)

            # 烈焰震击
            self.pubAvgColorTiggerKeyCDMode(73, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '8', 0.06, 2)
            # 治疗之泉图腾
            self.pubAvgColorTiggerKeyCDMode(114, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '2', 0.06, 2)

            # 毁灭闪电
            self.pubAvgColorTiggerKeyCDMode(149, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '5', 0.06, 2)

            # 大地之刺
            self.pubAvgColorTiggerKeyCDMode(184, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '4', 0.06, 2)

            # 冰霜震击
            self.pubAvgColorTiggerKeyCDMode(254, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', 't', 0.06, 2)

            # 火焰新星
            self.pubAvgColorTiggerKeyCDMode(288, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '\\', 0.06, 2)

        return

    def parallelCtrl5(self):
        # while self.ui.stopLoop == False:
        #     self.click(self.kb, '2', 3)
        #     sleep(0.1)
        pass
        return

    def parallelCtrl6(self):
        # while self.ui.stopLoop == False:
        #     self.click(self.kb, '`', 3)
        #     sleep(2)
        pass
        return

    def on_mouse_click_son_before_thread(self, x, y, button, pressed):
        # self.interruptAllByForce()
        pass
        return

    def mouseUp(self, x, y):
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        for i in range(1, 20):
            self.click(self.kb, 'b', 2)
            sleep(0.01)
        log.debug('★鼠标向上滚，需要over执行的内容★')
        return

    def mouseDown(self, x, y):
        for i in range(1, 20):
            self.click(self.kb, '0', 2)
            sleep(0.2)
        return

    def space(self):
        if self.ui.checkBox_SM_Jump2Wolf.isChecked() == True:
            self.click(self.kb, '.', 3)
        return

    def q(self):
        self.click(self.kb, 'o', 2)
        return

    def z(self):
        # 直接终止一切鼠标，键盘动作。
        self.stopLoop = True
        self.interruptAllByForce()
        return


class HealShaman(Player):

    def mouseUp(self, x, y):

        self.click(self.kb, ',', 4)

        while self.ui.stopLoop == False:
            # 收割链
            self.pubAvgColorTiggerKeyCDMode(135, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', ',', 0.1, 4)
            self.click(self.kb, '2', 2)
            sleep(0.01)
            self.click(self.kb, '7', 3)

    def mouseDown(self, x, y):

        self.kb.press('`')  # 触发-->parallel1
        self.kb.release('`')

        # while self.ui.stopLoop == False:
        while self.ui.stopLoop == False:
            # 暴雨图腾
            self.pubAvgColorTiggerKeyCDMode(18, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '3', 0.06, 2)
            # 大地之墙图腾
            # self.pubAvgColorTiggerKeyCDMode(96, self.WA_SQUARE_ZFX, 10, 10, self.WA_SQUARE_ZFX_AvgColor, 'r', 'big', '5', 0.1, 2)
            # # 法力图腾
            self.pubAvgColorTiggerKeyCDMode(1430, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WABloodBarAvgColor,
                                            'r', 'big', 'i', 0.06, 2)
            # # 土元素(焦点血量低于)
            # self.pubAvgColorTiggerKeyCDMode(500, 1036, self.WABloodBarDeltaX, self.WABloodBarDeltaY, self.WABloodBarAvgColor,
            #                                 'r', 'big', 't', 0.1, 2)
            # 暮钟图腾
            # self.pubAvgColorTiggerKeyCDMode(1340, 1037, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 'r', 'big', '6', 0.1, 3)
            # 收割链(节约用，不能随意触发)
            avgColorNumber = self.pubAvgColorNoTrigger(500, self.WABloodBarY, self.WABloodBarDeltaX + 7,
                                                       self.WABloodBarDeltaY, 'r', 0.06)
            if avgColorNumber < self.WABloodBarAvgColor:
                self.pubAvgColorTiggerKeyCDMode(135, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                self.WA_SQUARE_ZFX_AvgColor,
                                                'r', 'big', ',', 0.06, 2)

            # 血量低于xx多少，触发开启饰品
            self.pubAvgColorTiggerKeyBloodBarMode(523, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', ';', 0.06, 2)

            # 血量低于xx多少，触发开启灵魂链接图腾
            self.pubAvgColorTiggerKeyBloodBarMode(470, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', '=', 0.06, 2)

            # 血量低于xx多少，触发土元素
            self.pubAvgColorTiggerKeyBloodBarMode(480, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', 't', 0.06, 2)

            # 蓝量低于多少，开启法力图腾
            self.pubAvgColorTiggerKeyBloodBarMode(1400, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', 'i', 0.06, 2)

            # 血量低于xx多少，触发升腾
            self.pubAvgColorTiggerKeyBloodBarMode(450, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', 'o', 0.06, 2)

            # 血量低于xx多少，吃术士糖
            self.pubAvgColorTiggerKeyBloodBarMode(500, self.WABloodBarY, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, 'r', 'small', '-', 0.06, 2)

            # 焦点坦克血量（首先要有底部的血，怕自己忘记设置T为焦点而失误放出技能）
            avgColorNumber = self.pubAvgColorNoTrigger(420, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                       self.WABloodBarDeltaX + 7,
                                                       self.WABloodBarDeltaY, 'r', 0.06)
            if avgColorNumber > self.WABloodBarAvgColor:
                # *******************进入这里，才说明了设置坦克为焦点，才会触发对坦克血量判断的逻辑*******************
                # 焦点坦克血量低于xx多少，触发开启饰品
                self.pubAvgColorTiggerKeyBloodBarMode(523, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                      self.WABloodBarDeltaX,
                                                      self.WABloodBarDeltaY,
                                                      self.WABloodBarAvgColor, 'r', 'small', ';', 0.06, 2)

                # 焦点坦克血量低于xx多少，触发土元素
                self.pubAvgColorTiggerKeyBloodBarMode(500, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                      self.WABloodBarDeltaX,
                                                      self.WABloodBarDeltaY,
                                                      self.WABloodBarAvgColor, 'r', 'small', 't', 0.06, 2)

                # $$$$$$$$$$$$$$$$焦点坦克的血和自己奶萨的血，都低于多少的时候，触发灵魂链接图腾$$$$$$$$$$$$$$$$ #
                avgColorNumberTank = self.pubAvgColorNoTrigger(466, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                               self.WABloodBarDeltaX + 7,
                                                               self.WABloodBarDeltaY, 'r', 0.06)
                avgColorNumberMe = self.pubAvgColorNoTrigger(466, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                             self.WABloodBarDeltaX + 7,
                                                             self.WABloodBarDeltaY, 'r', 0.06)
                if avgColorNumberTank < self.WABloodBarAvgColor and avgColorNumberMe < self.WABloodBarAvgColor:
                    for i in range(1, 3):
                        # 灵魂链接图腾
                        self.click(self.kb, '=', 3)
                        sleep(0.1)

                # $$$$$$$$$$$$$$$$焦点坦克的血和自己奶萨的血，都低于多少的时候，触发灵魂链接图腾$$$$$$$$$$$$$$$$ #
                # +7是应为血条长一点，平均下来，避免色差
                avgColorNumberTank = self.pubAvgColorNoTrigger(500, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                               self.WABloodBarDeltaX + 7,
                                                               self.WABloodBarDeltaY, 'r', 0.06)
                # +7是应为血条长一点，平均下来，避免色差
                avgColorNumberMe = self.pubAvgColorNoTrigger(500, self.WABloodBarY - self.WABlood1_Blood2_DeltaY,
                                                             self.WABloodBarDeltaX + 7,
                                                             self.WABloodBarDeltaY, 'r', 0.06)
                if avgColorNumberTank < self.WABloodBarAvgColor and avgColorNumberMe < self.WABloodBarAvgColor:
                    for i in range(1, 3):
                        # 升腾
                        self.click(self.kb, 'o', 3)
                        sleep(0.1)
            else:
                # 忘记设置焦点，或者坦克立刻就要空血
                pass

    def parallel1(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        while self.ui.stopLoop == False:
            # 激流
            self.click(self.kb, '2', 2)
            sleep(0.2)
            # 生命释放
            # self.pubAvgColorTiggerKeyCDMode(57, self.WA_SQUARE_ZFX, 10, 10, self.WA_SQUARE_ZFX_AvgColor, 'r', 'big', '4', 0.1, 2)
            # 治疗之涌
            self.click(self.kb, '1', 4)

    def a(self):

        # while self.ui.stopLoop == False:
        while self.ui.stopLoop == False:
            # 打输出
            self.click(self.kb, 'n', 2)
            sleep(0.1)
            self.click(self.kb, 'b', 2)

    def on_mouse_scroll_son_before_thread(self, dx, dy):
        if dy < 0:
            # 滚轮向下
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        elif dy > 0:
            # 滚轮向上
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        return

    def space(self):
        # 跳的时候，是根据界面的变量来决定是否同时变狼的
        if self.ui.checkBox_SM_Jump2Wolf.isChecked() == True:
            self.click(self.kb, '.', 3)
        return

    def q(self):
        # 大地之盾
        self.click(self.kb, 'k', 6)
        return

    def r(self):
        # while self.ui.stopLoop == False:
        while self.ui.stopLoop == False:
            # 暴雨图腾
            self.pubAvgColorTiggerKeyCDMode(18, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '3', 0.1, 2)
            # sleep(0.1)
            self.click(self.kb, '2', 3)
            self.pubAvgColorTiggerKeyCDMode(57, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '4', 0.1, 2)
            # sleep(0.1)
            self.click(self.kb, '1', 4)
            # sleep(0.1)
            self.pubAvgColorTiggerKeyCDMode(96, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '5', 0.1, 2)
            self.pubAvgColorTiggerKeyCDMode(1340, 1037, self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                            self.WA_SQUARE_ZFX_AvgColor,
                                            'r', 'big', '6', 0.1, 2)

    def mouseRightClick(self, x, y):
        log.debug('★治疗SM鼠标click-right，需要开始执行的内容★')
        return

    def parallelAlt2(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        while self.ui.stopLoop == False:
            # sleep(0.01)
            # self.click(self.kb, 't', 3)
            # sleep(0.01)
            sleep(1)
            pass

    def w(self):
        for i in range(1, 4):
            self.click(self.kb, 'p', 2)
            sleep(0.1)

        # 打断后的继续
        self.click(self.kb, 'a', 1)
        return

    def x(self):
        for i in range(1, 4):
            self.click(self.kb, ']', 2)
            sleep(0.1)

        # 打断后的继续
        self.click(self.kb, 'r', 1)
        return

    def c(self):
        for i in range(1, 4):
            self.click(self.kb, '[', 2)
            sleep(0.1)

        # 打断后的继续
        self.click(self.kb, 'a', 1)
        return


class ElementShaman(Player):
    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        # super().a()

        # ★★★★★并行|并发★★★★★----------------parallel:`1   Alt2     cap3    shift4   ctrl5
        self.kb.press('`')  # 触发-->parallel1
        self.kb.release('`')

        self.kb.press(Key.alt_l)
        self.kb.release(Key.alt_l)
        #
        # self.kb.press(Key.caps_lock)
        # self.kb.release(Key.caps_lock)
        #
        # self.kb.press(Key.ctrl_l)
        # self.kb.release(Key.ctrl_l)

        while self.ui.stopLoop == False:
            # print('开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始开始')
            avgColorNumber = self.pubAvgColorNoTrigger(92, 52, 65, 2, 'b', 0.7)

            # print('颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色颜色:' + str(avgColorNumber))
            if self.AOE == True:
                if avgColorNumber > 150:
                    for i in range(1, 3):
                        self.click(self.kb, '6', 1)
                        self.stopShareLoop = True
                        # print('停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止停止')
                else:
                    # print('重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动1111:' + str(self.stopShareLoop))
                    self.stopShareLoop = False
                    # print('重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动重新启动2222"' + str(self.stopShareLoop))
            else:
                self.stopShareLoop = False
                if avgColorNumber > 150:
                    for i in range(1, 3):
                        self.click(self.kb, '5', 4)

    def parallel1(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        while self.ui.stopLoop == False:
            if self.stopShareLoop == False:
                # self.click(self.kb, '7', 4)
                # sleep(0.1)
                self.click(self.kb, '1', 6)
                sleep(8)

    def parallelAlt2(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        while self.ui.stopLoop == False:
            # print('退休金退休金退休金退休金退休金退休金退休金退休金退休金退休金退休金退休金退休金333:' + str(self.stopShareLoop))
            if self.stopShareLoop == False:
                self.click(self.kb, '2', 4)
                sleep(0.1)
                self.click(self.kb, '3', 3)
                sleep(0.1)
                self.click(self.kb, '4', 3)
                sleep(0.1)
                self.click(self.kb, '7', 3)
                sleep(0.1)
                self.click(self.kb, ']', 3)
                sleep(0.1)

    def parallelCap3(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        # for i in range(1, 888888):
        #     self.click(self.kb, '4', 3)
        #     sleep(0.01)
        pass
        return

    def on_mouse_click_son_before_thread(self, x, y, button, pressed):
        # self.interruptAllByForce()
        pass
        return

    def mouseUp(self, x, y):
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        self.AOE = True
        pass
        log.debug('★鼠标向上滚，需要over执行的内容★')
        return

    def mouseDown(self, x, y):
        self.AOE = False
        # for i in range(1, 888888):
        #     self.click(self.kb, '0', 2)
        #     sleep(0.01)
        pass
        return

    def space(self):
        if self.ui.checkBox_SM_Jump2Wolf.isChecked() == True:
            self.click(self.kb, '.', 3)
        return

    def q(self):
        self.click(self.kb, 'k', 2)
        return


if __name__ == '__main__':
    pass
